package com.bona.service.report;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.bona.dao.common.BaseDao;
import com.bona.dao.report.ReportItemDao;
import com.bona.model.report.ReportItemModel;
import com.bona.service.common.BaseService;
import com.bona.util.common.StringUtil;
import com.bona.util.common.UUIDGenerator;

@Service("reportItemService")
@Transactional
public class ReportItemService extends BaseService {

	@Autowired
	private ReportItemDao reportItemDao;
	
	@Override
	public BaseDao getDao() {
		return reportItemDao;
	}

	/**
	 * 添加或更新分组信息
	 * @param model
	 */
	public void addOrUpdate(ReportItemModel model) {
		
		if (StringUtil.isEmpty(model.getId())) {	// 新增分组信息
			model.setId(UUIDGenerator.generate());
			reportItemDao.add(model);
			return;
		}
		reportItemDao.update(model);
	}

}
